<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>数据表格</title>
    <link rel="stylesheet" href="component/pear/css/pear.css" />
</head>
<body class="pear-container">

<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" action="" onsubmit="return false">

            <div class="layui-form-item">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-block">
                    <input type="text" name="userName" required  lay-verify="required" placeholder="请输入用户名称" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" required  lay-verify="required" placeholder="请输入用户密码" autocomplete="off" class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-block">
                    <input type="text" name="phone" required  lay-verify="required" placeholder="请输入手机号" autocomplete="off" class="layui-input">
                </div>
            </div>

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="radio" name="type" value="1" title="家教">
					<input type="radio" name="type" value="2" title="学生" checked>
				</div>
			</div>
			
<!--            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">地址</label>
                <div class="layui-input-block">
                    <textarea name="address" placeholder="请输入用户地址" class="layui-textarea"></textarea>
                </div>
            </div> -->

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" lay-submit lay-filter="save">立即提交</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>

        </form>
    </div>
</div>

<script src="component/layui/layui.js"></script>
<script src="component/pear/pear.js"></script>
<script src="api/baseApi.js" ></script>
<script src="api/userApi.js"></script>
<script src="component/js/core.util.js"></script>

<script>
    layui.use(['table', 'form', 'jquery', 'drawer', 'dropdown'], function() {
        let table = layui.table;
        let form = layui.form;
        let $ = layui.jquery;
        let drawer = layui.drawer;
        let dropdown = layui.dropdown;

        form.on('submit(save)', function(data) {
            console.info(data.field)
            data.field.userType = 2;
            coreUtil.sendAjax(saveUrl, JSON.stringify(data.field), function (res) {
                layer.msg("添加成功", {icon: 1,time: 1000}, function () {
                    // 刷新当前页
                    window.location.reload()
                });
            }, "POST", false)
            return false;
        });
    })

</script>
</body>
</html>
